/*
 * 
 * 
 * 
 */
package com.hboxs.asl.controller.admin;

import com.hboxs.asl.entity.Platform;
import com.hboxs.asl.service.PlatformService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpSession;

import javax.annotation.Resource;

/**
 * Controller - 平台
 */
@Controller("adminPlatformController")
@RequestMapping("/asl-admin/platform")
public class PlatformController extends BaseController {

    @Resource(name = "platformServiceImpl")
    private PlatformService platformService;

    /**
     * 编辑
     */
    @RequestMapping(value = "/edit", method = RequestMethod.GET)
    public String edit(Long id, ModelMap model, HttpSession session) {
        model.addAttribute("platform", platformService.getUniqueness());
        return "/admin/platform/edit";
    }

    /**
     * 更新
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public String update(Platform platform, RedirectAttributes redirectAttributes) {
        if (!isValid(platform)) {
            return ERROR_VIEW;
        }
        platformService.update(platform, "");
        addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
        return "redirect:list.htm";
    }


}
